#include <vector>
#include <iostream>

using namespace std;

vector<vector<int>> powerSet(vector<int> array) {
  vector<vector<int>> ans {{}};
  for(int i : array) {
    int length = ans.size();
    for(int j = 0; j < length; ++j) {
      vector<int> tmp = ans[j];
      tmp.push_back(i);
      ans.push_back(tmp);
    }
  }
  return ans;
}

int main(int argc, char const *argv[]) {
  vector<int> arr {1, 2, 3};
  vector<vector<int>> s = powerSet(arr);
  for(vector<int> i : s) {
    cout << "[" ;
    for(int n: i) {
      cout << n << " ";
    }
    cout << "]";
  }
  cout << endl;
  return 0;
}

